 package com.zhike.b2b.company.impl;
 
 import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import com.saas.biz.commen.CommGetId;
import com.saas.biz.commen.CommMethodMgr;
import com.saas.biz.commen.Thumbnail;
import com.saas.biz.dao.companyDAO.CompanyExt;
import com.saas.biz.dao.companyauthDAO.CompanyauthDAO;
import com.saas.biz.dao.companyauthDAO.CompanyauthExt;
import com.saas.biz.dao.custDAO.CustomerExt;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.exp.SaasApplicationException;
import com.zhike.b2b.base.BaseService;
import com.zhike.b2b.dao.Dbtable;
 
@Service
 public class Companyauth extends BaseService
 {
	 Logger log = LoggerFactory.getLogger(Companyauth.class);
	 
   Buffers inBuffer;
   Buffers outBuffer;
   Dbtable tradeQuery;
   CommMethodMgr commen;
   ArrayList queryResult;
 
   public Companyauth()
   {
    queryResult = new ArrayList();
    
    tradeQuery = new Dbtable();
    commen = new CommMethodMgr();
     outBuffer = new Buffers();
   }
 
   public void setOutBuffer(Buffers buffers) {
     outBuffer = buffers;
   }
 
   public Buffers getOutBuffer()
   {
     return outBuffer;
   }
 
   public void setTradeQuery(Dbtable dbtable)
   {
     tradeQuery = dbtable;
   }
 
   public Dbtable getTradeQuery()
   {
     return tradeQuery;
   }
 
   public ArrayList getQueryResult()
   {
     return queryResult;
   }
 
   public void setQueryResult(ArrayList arraylist)
   {
     queryResult = arraylist;
   }
 
   public ArrayList getRegisterImage(String cust_id)
     throws SaasApplicationException
   {
     ArrayList arraylist = new ArrayList();
     CompanyauthExt companyauthext = new CompanyauthExt();
     companyauthext.setParam(":VCUST_ID", cust_id);
     arraylist = companyauthext.selByList("SEL_IMG_BY_CUST_ID");
     return arraylist;
   }
 
   public void delRegisterImage(Buffers inbuffer)
     throws IOException
   {
     outBuffer = inbuffer;
     inBuffer = inbuffer;
     int iResult = -1;
     String cust_id = inbuffer.getStringWeb("cust_id");
     try {
       iResult = delRegisterImage(cust_id);
     } catch (SaasApplicationException e) {
       log.error(e.getMessage());
     }
     if (iResult != 0) {
       outBuffer.setInt("RESULT_CODE", -1);
       outBuffer.setString("RESULT_INFO", "业务处理失败！");
     } else {
       outBuffer.setInt("RESULT_CODE", 0);
       outBuffer.setString("RESULT_INFO", "业务处理成功！");
     }
   }
 
   public int delRegisterImage(String cust_id) throws SaasApplicationException {
     CompanyauthExt companyauthext = new CompanyauthExt();
     companyauthext.setParam(":VCUST_ID", cust_id);
     tradeQuery.executeBy(companyauthext.insCompanyAuthBy("DEL_COMPANYAUTH_IMG_BY_CUSTID"));
     return 0;
   }
 
   public void addRegisterImg(Buffers inbuffer)
   {
     outBuffer = inbuffer;
     inBuffer = inbuffer;
 
     int iResult = -1;
     try {
       CommMethodMgr comm = new CommMethodMgr();
 
       String upDir = inbuffer.getString("UPLOADFILEDIR");
 
       CompanyauthDAO companyauthDAO = new CompanyauthDAO();
 
       companyauthDAO.setCust_id(inbuffer.getString("SESSION_CUST_ID"));
       companyauthDAO.setRegister_attach(upDir);
 
       String headDir = upDir.substring(0, upDir.lastIndexOf("/"));
       iResult = addRegisterImg(companyauthDAO, headDir);
     } catch (SaasApplicationException e) {
       log.error(e.getMessage());
     }
     if (iResult != 0) {
       outBuffer.setInt("RESULT_CODE", -1);
       outBuffer.setString("RESULT_INFO", "业务处理失败！");
     } else {
       outBuffer.setInt("RESULT_CODE", 0);
       outBuffer.setString("RESULT_INFO", "业务处理成功！");
     }
   }
 
   public int addRegisterImg(CompanyauthDAO companyauthDAO, String realdir)
     throws SaasApplicationException
   {
     CommMethodMgr comm = new CommMethodMgr();
 
     CompanyauthExt companyauthext = new CompanyauthExt();
     String[] OldimagePath = companyauthDAO.getRegister_attach().trim().split("/");
 
     String strFilename = OldimagePath[(OldimagePath.length - 1)];
     log.debug("strFilename=" + strFilename);
     try {
       log.info("====" + new String(strFilename.getBytes("UTF-8"), "ISO-8859-1"));
     }
     catch (UnsupportedEncodingException e) {
       e.printStackTrace();
     }
 
     String weburl = "/upload/" + companyauthDAO.getCust_id() + "/" + strFilename;
     log.debug("weburl=" + weburl);
 
     companyauthext.setParam(":VREGISTER_ATTACH", weburl);
     companyauthext.setParam(":VCUST_ID", companyauthDAO.getCust_id());
 
     tradeQuery.executeBy(companyauthext.insCompanyAuthBy("INS_IMG_BY_CUSTID"));
 
     outBuffer.setString("FILENAME", "/upload/" + companyauthext.getCust_id() + "/" + strFilename);
     return 0;
   }
 
   public void insertCompanyauthInfo(Buffers inbuffer)
     throws SaasApplicationException
   {
     log.debug("************111******************");
     outBuffer = inbuffer;
     log.info("进入insertCompanyauthInfo方法...");
     CommGetId comm = new CommGetId();
     String exhibition_period = ""; String company_auth_id_ins = ""; String logo_img = ""; String save = ""; String register_attach = ""; String xiaoshou_all_news_id = ""; String caigou_all_news_id = ""; String oper_user = ""; String company_auth_id = ""; String companyauth_email = ""; String email = ""; String cust_id = ""; String user_id = ""; String info_auth = ""; String cust_name = ""; String juristic = ""; String abbreviated = ""; String enterprise_type_code = ""; String eparchy_code = ""; String group_contact_phone = ""; String fax_nbr = ""; String website = ""; String post_code = ""; String pspt_id = ""; String company_address = ""; String bank_deposit = ""; String bank_account = ""; String banking_account = ""; String user_count = ""; String certification = ""; String cust_rage = ""; String company_scope = "";
 
     String type = "";
     xiaoshou_all_news_id = inbuffer.getString("XIAOSHOU_ALL_NEWS_ID");
     caigou_all_news_id = inbuffer.getString("CAIGOU_ALL_NEWS_ID");
     
              logo_img = inbuffer.getString("LOGO");
     save = inbuffer.getString("SAVE");
     register_attach = inbuffer.getString("REGISTER_ATTACH");
     info_auth = inbuffer.getString("INFO_AUTH");
     oper_user = inbuffer.getString("SESSION_USER_ID");
     company_auth_id = inbuffer.getString("COMPANY_AUTH_ID");
     company_auth_id_ins = comm.getTradeId("company_auth", "company_auth_id");
     email = inbuffer.getString("email");
     cust_id = inbuffer.getString("SESSION_CUST_ID");
     user_id = inbuffer.getString("USER_ID");
     cust_name = inbuffer.getString("CUST_NAME");
     juristic = inbuffer.getString("JURISTIC");
     abbreviated = inbuffer.getString("ABBREVIATED");
     enterprise_type_code = inbuffer.getString("ENTERPRISE_TYPE_CODE");
     eparchy_code = inbuffer.getString("EPARCHY_CODE");
     group_contact_phone = inbuffer.getString("GROUP_CONTACT_PHONE");
     fax_nbr = inbuffer.getString("FAX_NBR");
     website = inbuffer.getString("WEBSITE");
     post_code = inbuffer.getString("POST_CODE");
     pspt_id = inbuffer.getString("PSPT_ID");
     company_address = inbuffer.getString("COMPANY_ADDRESS");
     bank_deposit = inbuffer.getString("BANK_DEPOSIT");
     bank_account = inbuffer.getString("BANK_ACCOUNT");
     banking_account = inbuffer.getString("BANKING_ACCOUNT");
     user_count = inbuffer.getString("USER_COUNT");
     certification = inbuffer.getString("CERTIFICATION");
     cust_rage = inbuffer.getString("CUST_RAGE");
     company_scope = inbuffer.getString("COMPANY_SCOPE");
     type = inbuffer.getString("TYPE");
 
     exhibition_period = inbuffer.getString("EXHIBITION_PERIOD");
 
     int iResult = -1;
     try {
       iResult = insertCompanyauthInfo(inbuffer, exhibition_period, company_auth_id_ins, logo_img, save, xiaoshou_all_news_id, caigou_all_news_id, register_attach, oper_user, company_auth_id, email, cust_id, user_id, info_auth, cust_name, juristic, abbreviated, enterprise_type_code, eparchy_code, group_contact_phone, fax_nbr, website, post_code, pspt_id, company_address, bank_deposit, bank_account, banking_account, user_count, certification, cust_rage, company_scope, type);
     } catch (SaasApplicationException e) {
       log.info(e.getMessage());
     }
     if (iResult != 0) {
       outBuffer.setInt("RESULT_CODE", -1);
       outBuffer.setString("RESULT_INFO", "业务处理失败！");
     }
     else {
       outBuffer.setInt("RESULT_CODE", 0);
       outBuffer.setString("RESULT_INFO", "业务处理成功！");
     }
     log.info("退出DEleteContentinfo方法...");
   }
   public int insertCompanyauthInfo(Buffers inbuffer, String exhibition_period, String company_auth_id_ins, String logo_img, String save, String xiaoshou_all_news_id, String caigou_all_news_id, String register_attach, String oper_user, String company_auth_id, String email, String cust_id, String user_id, String info_auth, String cust_name, String juristic, String abbreviated, String enterprise_type_code, String eparchy_code, String group_contact_phone, String fax_nbr, String website, String post_code, String pspt_id, String company_address, String bank_deposit, String bank_account, String banking_account, String user_count, String certification, String cust_rage, String company_scope, String type) throws SaasApplicationException {
     CompanyauthExt companyauthExt = new CompanyauthExt();
     companyauthExt.setParam(":VCOMPANY_AUTH_ID_INS", company_auth_id_ins);
 
     companyauthExt.setParam(":VXIAOSHOU_ALL_NEWS_ID", xiaoshou_all_news_id);
     companyauthExt.setParam(":VCAIGOU_ALL_NEWS_ID", caigou_all_news_id);
     companyauthExt.setParam(":VCOMPANY_AUTH_ID", company_auth_id);
     companyauthExt.setParam(":VREGISTER_ATTACH", register_attach);
     companyauthExt.setParam(":VOPER_USER", oper_user);
     companyauthExt.setParam(":VEMAIL", email);
     companyauthExt.setParam(":VCUST_ID", cust_id);
     companyauthExt.setParam(":VUSER_ID", user_id);
     companyauthExt.setParam(":VCUST_NAME", cust_name);
     companyauthExt.setParam(":VJURISTIC", juristic);
     companyauthExt.setParam(":VABBREVIATED", abbreviated);
     companyauthExt.setParam(":VENTERPRISE_TYPE_CODE", enterprise_type_code);
     companyauthExt.setParam(":VEPARCHY_CODE", eparchy_code);
     companyauthExt.setParam(":VGROUP_CONTACT_PHONE", group_contact_phone);
     companyauthExt.setParam(":VFAX_NBR", fax_nbr);
     companyauthExt.setParam(":VWEBSITE", website);
     companyauthExt.setParam(":VPOST_CODE", post_code);
     companyauthExt.setParam(":VPSPT_ID", pspt_id);
     companyauthExt.setParam(":VCOMPANY_ADDRESS", company_address);
     companyauthExt.setParam(":VBANK_DEPOSIT", bank_deposit);
     companyauthExt.setParam(":VBANK_ACCOUNT", bank_account);
     companyauthExt.setParam(":VBANKING_ACCOUNT", banking_account);
     companyauthExt.setParam(":VUSER_COUNT", user_count);
     companyauthExt.setParam(":VCERTIFICATION", certification);
     companyauthExt.setParam(":VCUST_RAGE", cust_rage);
     companyauthExt.setParam(":VCOMPANY_SCOPE", company_scope);
     companyauthExt.setParam(":VLOGO_IMG", logo_img);
     companyauthExt.setParam(":VTYPE", type);
     companyauthExt.setParam(":VEXHIBITION_PERIOD", exhibition_period);
 
     String pic_path = logo_img;
     if ((pic_path != null) && (!pic_path.equals(""))) {
       new Thumbnail().creatThumbnail("company", pic_path);
     }
 
     ArrayList arraylist = new ArrayList();
     CompanyauthExt companyauthext = new CompanyauthExt();
     companyauthext.setParam(":VCUST_ID", cust_id);
     arraylist = companyauthext.selByList("SEL_INFO_TO_COMPANYAUTH");
     String upCode = inbuffer.getString("code");
 
     if ("1".equals(save)) {
       log.debug("进入保存处理");
       if ((arraylist != null) && (arraylist.size() > 0)) {
         tradeQuery.executeBy(companyauthExt.insCompanyAuthBy("UPDATE_COMPANYAUTH_ALL_INFOAUTH_SAVE"));
         tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_FOUR_INFOAUTH"));
       } else {
         tradeQuery.executeBy(companyauthExt.insCompanyAuthBy("INSERT_COMPANYAUTH_INFO_ALL"));
         tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_FOUR_INFOAUTH"));
       }
     } else {
       if ("".equals(info_auth))
       {
         tradeQuery.executeBy(companyauthExt.insCompanyAuthBy("INSERT_COMPANYAUTH_INFO_ALL"));
         tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_ZERO_INFOAUTH"));
       }
 
       if (("1".equals(info_auth)) || ("2".equals(info_auth)) || ("4".equals(info_auth)))
       {
         if (!exhibition_period.equals("")) {
           companyauthExt.setParam(":VEXHIBITION_PERIOD", Integer.valueOf(new Integer(exhibition_period).intValue()));
           tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_ALL_INFOAUTH_TOW"));
         } else {
           tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_ALL_INFOAUTH_TOWWW"));
         }
         tradeQuery.executeBy(companyauthExt.insCompanyAuthBy("INSERT_COMPANYAUTH_ALL_INFOAUTH_TOW"));
       }
 
     }
 
     return 0;
   }
   private String getloGo(String cust_id) {
     String logo_path = "";
     String sql = "select logo_img from company_auth where cust_id=" + cust_id;
     List<String> ls = jt.query(sql, new RowMapper<String>(){
          public String mapRow(ResultSet rs, int arg1) throws SQLException {
			return rs.getString("logo_img");
		}
      });
     if(ls!=null&&ls.size()>0)
         logo_path = ls.get(0);
     return logo_path;
   }
 
   private void upType(String type, String cust_id)
   {
     CompanyExt comExt = new CompanyExt();
     comExt.setParam(":VTYPE", type);
     comExt.setParam(":VCUST_ID", cust_id);
     if (!type.equals(""))
       tradeQuery.executeBy(comExt.insBy("UP_TYPE"));
   }
 
   public ArrayList getCompanyanthInfo(String cust_id)
     throws SaasApplicationException
   {
     ArrayList arraylist = new ArrayList();
     CompanyauthExt companyauthext = new CompanyauthExt();
     companyauthext.setParam(":VCUST_ID", cust_id);
     arraylist = companyauthext.selByList("SEL_COMPANYAUTH_BY_CUSTID_INFOSEE");
     return arraylist;
   }
 
   public ArrayList getCompanyanthInfoAll(String cust_id)
     throws SaasApplicationException
   {
     ArrayList arraylist = new ArrayList();
     CompanyauthExt companyauthext = new CompanyauthExt();
     companyauthext.setParam(":VCUST_ID", cust_id);
     arraylist = companyauthext.selByList("SEL_COMPANYAUTH_BY_CUSTID_INFOSEE_ALL");
     return arraylist;
   }
 
   public void insertCompanyauthandCompanyInfo(Buffers inbuffer)
     throws SaasApplicationException
   {
     outBuffer = inbuffer;
     log.info("进入updateCompanyContentInfo方法...");
     String exhibition_period = ""; String logo_img = ""; String xiaoshou_all_news_id = ""; String caigou_all_news_id = ""; String register_attach = ""; String company_auth_id = ""; String companyauth_email = ""; String email = ""; String cust_id = ""; String user_id = ""; String info_auth = ""; String cust_name = ""; String juristic = ""; String abbreviated = ""; String enterprise_type_code = ""; String eparchy_code = ""; String group_contact_phone = ""; String fax_nbr = ""; String website = ""; String post_code = ""; String pspt_id = ""; String company_address = ""; String bank_deposit = ""; String bank_account = ""; String banking_account = ""; String user_count = ""; String certification = ""; String cust_rage = ""; String company_scope = "";
     String type = "";
     logo_img = inbuffer.getString("LOGO");
     exhibition_period = inbuffer.getString("EXHIBITION_PERIOD");
     xiaoshou_all_news_id = inbuffer.getString("XIAOSHOU_ALL_NEWS_ID");
     caigou_all_news_id = inbuffer.getString("CAIGOU_ALL_NEWS_ID");
     info_auth = inbuffer.getString("INFO_AUTH");
     register_attach = inbuffer.getString("REGISTER_ATTACH");
     company_auth_id = inbuffer.getString("COMPANY_AUTH_ID");
     email = inbuffer.getString("email");
     cust_id = inbuffer.getString("SESSION_CUST_ID");
     user_id = inbuffer.getString("USER_ID");
     cust_name = inbuffer.getString("CUST_NAME");
     juristic = inbuffer.getString("JURISTIC");
     abbreviated = inbuffer.getString("ABBREVIATED");
     enterprise_type_code = inbuffer.getString("ENTERPRISE_TYPE_CODE");
     eparchy_code = inbuffer.getString("EPARCHY_CODE");
     group_contact_phone = inbuffer.getString("GROUP_CONTACT_PHONE");
     fax_nbr = inbuffer.getString("FAX_NBR");
     website = inbuffer.getString("WEBSITE");
     post_code = inbuffer.getString("POST_CODE");
     pspt_id = inbuffer.getString("PSPT_ID");
     company_address = inbuffer.getString("COMPANY_ADDRESS");
     bank_deposit = inbuffer.getString("BANK_DEPOSIT");
     bank_account = inbuffer.getString("BANK_ACCOUNT");
     banking_account = inbuffer.getString("BANKING_ACCOUNT");
     user_count = inbuffer.getString("USER_COUNT");
     certification = inbuffer.getString("CERTIFICATION");
     cust_rage = inbuffer.getString("CUST_RAGE");
     company_scope = inbuffer.getString("COMPANY_SCOPE");
     type = inbuffer.getString("TYPE");
 
     int iResult = -1;
     try {
       iResult = insertCompanyauthandCompanyInfo(inbuffer, exhibition_period, logo_img, xiaoshou_all_news_id, caigou_all_news_id, register_attach, company_auth_id, email, cust_id, user_id, info_auth, cust_name, juristic, abbreviated, enterprise_type_code, eparchy_code, group_contact_phone, fax_nbr, website, post_code, pspt_id, company_address, bank_deposit, bank_account, banking_account, user_count, certification, cust_rage, company_scope, type);
     }
     catch (SaasApplicationException e)
     {
       log.info(e.getMessage());
     }
     if (iResult != 0) {
       outBuffer.setInt("RESULT_CODE", -1);
       outBuffer.setString("RESULT_INFO", "业务处理失败！");
     }
     else {
       outBuffer.setInt("RESULT_CODE", 0);
       outBuffer.setString("RESULT_INFO", "业务处理成功！");
     }
     log.info("退出DEleteContentinfo方法...");
   }
 
   public int insertCompanyauthandCompanyInfo(Buffers inbuffer, String exhibition_period, String logo_img, String xiaoshou_all_news_id, String caigou_all_news_id, String register_attach, String company_auth_id, String email, String cust_id, String user_id, String info_auth, String cust_name, String juristic, String abbreviated, String enterprise_type_code, String eparchy_code, String group_contact_phone, String fax_nbr, String website, String post_code, String pspt_id, String company_address, String bank_deposit, String bank_account, String banking_account, String user_count, String certification, String cust_rage, String company_scope, String type) throws SaasApplicationException {
     CompanyauthExt companyauthExt = new CompanyauthExt();
     companyauthExt.setParam(":VXIAOSHOU_ALL_NEWS_ID", xiaoshou_all_news_id);
     companyauthExt.setParam(":VCAIGOU_ALL_NEWS_ID", caigou_all_news_id);
     companyauthExt.setParam(":VREGISTER_ATTACH", register_attach);
     companyauthExt.setParam(":VCOMPANY_AUTH_ID", company_auth_id);
     companyauthExt.setParam(":VEMAIL", email);
     companyauthExt.setParam(":VCUST_ID", cust_id);
     companyauthExt.setParam(":VUSER_ID", user_id);
     companyauthExt.setParam(":VCUST_NAME", cust_name);
     companyauthExt.setParam(":VJURISTIC", juristic);
     companyauthExt.setParam(":VABBREVIATED", abbreviated);
     companyauthExt.setParam(":VENTERPRISE_TYPE_CODE", enterprise_type_code);
     companyauthExt.setParam(":VEPARCHY_CODE", eparchy_code);
     companyauthExt.setParam(":VGROUP_CONTACT_PHONE", group_contact_phone);
     companyauthExt.setParam(":VFAX_NBR", fax_nbr);
     companyauthExt.setParam(":VWEBSITE", website);
     companyauthExt.setParam(":VPOST_CODE", post_code);
     companyauthExt.setParam(":VPSPT_ID", pspt_id);
     companyauthExt.setParam(":VCOMPANY_ADDRESS", company_address);
     companyauthExt.setParam(":VBANK_DEPOSIT", bank_deposit);
     companyauthExt.setParam(":VBANK_ACCOUNT", bank_account);
     companyauthExt.setParam(":VBANKING_ACCOUNT", banking_account);
     companyauthExt.setParam(":VUSER_COUNT", user_count);
     companyauthExt.setParam(":VCERTIFICATION", certification);
     companyauthExt.setParam(":VCUST_RAGE", cust_rage);
     companyauthExt.setParam(":VCOMPANY_SCOPE", company_scope);
     companyauthExt.setParam(":VLOGO_IMG", logo_img);
     companyauthExt.setParam(":VTYPE", type);
     companyauthExt.setParam(":VEXHIBITION_PERIOD", exhibition_period);
 
     companyauthExt.setParam(":VOPER_USER", inbuffer.getString("SESSION_USER_ID"));
 
     String pic_path = logo_img;
     if ((pic_path != null) && (!pic_path.equals(""))) {
       new Thumbnail().creatThumbnail("company", pic_path);
     }
 
     ArrayList arraylist = companyauthExt.selByList("SEL_INFO_TO_COMPANYAUTH");
     String company_auth_id_ins = new CommGetId().getTradeId("company_auth", "company_auth_id");
     companyauthExt.setParam(":VCOMPANY_AUTH_ID_INS", company_auth_id_ins);
     String check_flag = ps.getParamValue("check_flag");
     if (("1".equals(info_auth)) || ("2".equals(info_auth)) || ("4".equals(info_auth)) || (info_auth.equals("firstreg")))
     {
       if (check_flag.equals("1")) {
         if ((arraylist == null) || (arraylist.size() <= 0)) {
           tradeQuery.executeBy(companyauthExt.insCompanyAuthBy("INSERT_COMPANYAUTH_INFO_ALL"));
         }
         tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_ALL_FIELD_INFOAUTH_TOW"));
       }
       else {
         if (!exhibition_period.equals("")) {
           companyauthExt.setParam(":VEXHIBITION_PERIOD", Integer.valueOf(new Integer(exhibition_period).intValue()));
           tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_FEIGUANJIAN_INFOAUTH_TOW"));
         } else {
           tradeQuery.executeBy(companyauthExt.insBy("UPDATE_COMPANY_FEIGUANJIAN_INFOAUTH_TOWW"));
         }
 
         tradeQuery.executeBy(companyauthExt.insCompanyAuthBy("INSERT_COMPANYAUTH_ALL_INFOAUTH_TOW"));
       }
     }
 
     return 0;
   }

   public String getTypeByIdd(String cust_id)
   {
     String type = "";
     String sql = "select type from company_auth where cust_id=" + cust_id;
     List<String> ls = jt.query(sql, new RowMapper<String>(){
         public String mapRow(ResultSet rs, int arg1) throws SQLException {
			return rs.getString("type");
		}
     });
    if(ls!=null&&ls.size()>0)
    	type = ls.get(0);
     return type;
   }
 
   public void insertCompanyauthInfoSave(Buffers inbuffer)
     throws SaasApplicationException
   {
     outBuffer = inbuffer;
     log.info("进入updateCompanyContentInfo方法...");
     String company_auth_id = ""; String companyauth_email = ""; String email = ""; String cust_id = ""; String user_id = ""; String info_auth = ""; String cust_name = ""; String juristic = ""; String abbreviated = ""; String enterprise_type_code = ""; String eparchy_code = ""; String group_contact_phone = ""; String fax_nbr = ""; String website = ""; String post_code = ""; String pspt_id = ""; String company_address = ""; String bank_deposit = ""; String bank_account = ""; String banking_account = ""; String user_count = ""; String certification = ""; String cust_rage = ""; String company_scope = "";
 
     info_auth = inbuffer.getString("INFO_AUTH");
 
     company_auth_id = inbuffer.getString("COMPANY_AUTH_ID");
     email = inbuffer.getString("email");
     cust_id = inbuffer.getString("SESSION_CUST_ID");
     user_id = inbuffer.getString("USER_ID");
     cust_name = inbuffer.getString("CUST_NAME");
     juristic = inbuffer.getString("JURISTIC");
     abbreviated = inbuffer.getString("ABBREVIATED");
     enterprise_type_code = inbuffer.getString("ENTERPRISE_TYPE_CODE");
     eparchy_code = inbuffer.getString("EPARCHY_CODE");
     group_contact_phone = inbuffer.getString("GROUP_CONTACT_PHONE");
     fax_nbr = inbuffer.getString("FAX_NBR");
     website = inbuffer.getString("WEBSITE");
     post_code = inbuffer.getString("POST_CODE");
     pspt_id = inbuffer.getString("PSPT_ID");
     company_address = inbuffer.getString("COMPANY_ADDRESS");
     bank_deposit = inbuffer.getString("BANK_DEPOSIT");
     bank_account = inbuffer.getString("BANK_ACCOUNT");
     banking_account = inbuffer.getString("BANKING_ACCOUNT");
     user_count = inbuffer.getString("USER_COUNT");
     certification = inbuffer.getString("CERTIFICATION");
     cust_rage = inbuffer.getString("CUST_RAGE");
     company_scope = inbuffer.getString("COMPANY_SCOPE");
 
     log.debug("--------------------------------------------------------------------------");
     log.debug("info_auth=" + info_auth);
 
     log.debug("company_auth_id=" + company_auth_id);
     log.debug("email=" + email);
     log.debug("cust_id=" + cust_id);
     log.debug("user_id=" + user_id);
     log.debug("cust_name=" + cust_name);
     log.debug("juristic=" + juristic);
     log.debug("abbreviated=" + abbreviated);
     log.debug("enterprise_type_code=" + enterprise_type_code);
     log.debug("eparchy_code=" + eparchy_code);
     log.debug("group_contact_phone=" + group_contact_phone);
     log.debug("fax_nbr=" + fax_nbr);
     log.debug("website=" + website);
     log.debug("post_code=" + post_code);
     log.debug("pspt_id=" + pspt_id);
     log.debug("company_address=" + company_address);
     log.debug("bank_deposit=" + bank_deposit);
     log.debug("bank_account=" + bank_account);
     log.debug("banking_account=" + banking_account);
     log.debug("user_count=" + user_count);
     log.debug("certification=" + certification);
     log.debug("cust_rage=" + cust_rage);
     log.debug("company_scope=" + company_scope);
     log.debug("--------------------------------------------------------------------------");
 
     int iResult = -1;
     try {
       iResult = insertCompanyauthInfoSave(company_auth_id, email, cust_id, user_id, info_auth, cust_name, juristic, abbreviated, enterprise_type_code, eparchy_code, group_contact_phone, fax_nbr, website, post_code, pspt_id, company_address, bank_deposit, bank_account, banking_account, user_count, certification, cust_rage, company_scope);
     }
     catch (SaasApplicationException e) {
       log.info(e.getMessage());
     }
     if (iResult != 0) {
       outBuffer.setInt("RESULT_CODE", -1);
       outBuffer.setString("RESULT_INFO", "业务处理失败！");
     }
     else {
       outBuffer.setInt("RESULT_CODE", 0);
       outBuffer.setString("RESULT_INFO", "业务处理成功！");
     }
     log.info("退出DEleteContentinfo方法...");
   }
 
   public int insertCompanyauthInfoSave(String company_auth_id, String email, String cust_id, String user_id, String info_auth, String cust_name, String juristic, String abbreviated, String enterprise_type_code, String eparchy_code, String group_contact_phone, String fax_nbr, String website, String post_code, String pspt_id, String company_address, String bank_deposit, String bank_account, String banking_account, String user_count, String certification, String cust_rage, String company_scope) throws SaasApplicationException {
     CompanyauthExt companyauthExt = new CompanyauthExt();
 
     companyauthExt.setParam(":VCOMPANY_AUTH_ID", company_auth_id);
     companyauthExt.setParam(":VEMAIL", email);
     companyauthExt.setParam(":VCUST_ID", cust_id);
     companyauthExt.setParam(":VUSER_ID", user_id);
     companyauthExt.setParam(":VCUST_NAME", cust_name);
     companyauthExt.setParam(":VJURISTIC", juristic);
     companyauthExt.setParam(":VABBREVIATED", abbreviated);
     companyauthExt.setParam(":VENTERPRISE_TYPE_CODE", enterprise_type_code);
     companyauthExt.setParam(":VEPARCHY_CODE", eparchy_code);
     companyauthExt.setParam(":VGROUP_CONTACT_PHONE", group_contact_phone);
     companyauthExt.setParam(":VFAX_NBR", fax_nbr);
     companyauthExt.setParam(":VWEBSITE", website);
     companyauthExt.setParam(":VPOST_CODE", post_code);
     companyauthExt.setParam(":VPSPT_ID", pspt_id);
     companyauthExt.setParam(":VCOMPANY_ADDRESS", company_address);
     companyauthExt.setParam(":VBANK_DEPOSIT", bank_deposit);
     companyauthExt.setParam(":VBANK_ACCOUNT", bank_account);
     companyauthExt.setParam(":VBANKING_ACCOUNT", banking_account);
     companyauthExt.setParam(":VUSER_COUNT", user_count);
     companyauthExt.setParam(":VCERTIFICATION", certification);
     companyauthExt.setParam(":VCUST_RAGE", cust_rage);
     companyauthExt.setParam(":VCOMPANY_SCOPE", company_scope);
 
     log.debug("----------------------READY-------------------------------");
     log.debug("进入保存操作方法");
 
     log.debug("准备执行SQL");
     tradeQuery.executeBy(companyauthExt.insCompanyAuthBy("UPDATE_COMPANYAUTH_FEIGUANJIAN_INFOAUTH_TOW"));
     log.debug("-------------------OVER----------------------------------");
 
     return 0;
   }
 
   public ArrayList getCompanyAuthInfoThree(String cust_id)
     throws SaasApplicationException
   {
     ArrayList arraylist = new ArrayList();
     CompanyauthExt companyauthext = new CompanyauthExt();
     companyauthext.setParam(":VCUST_ID", cust_id);
     arraylist = companyauthext.selByList("SEL_COMPANYAUTH_BY_CUST_ID_INFOSEE");
     return arraylist;
   }
 
   public ArrayList getCompanyAuthXINXI(String cust_id)
     throws SaasApplicationException
   {
     ArrayList arraylist = new ArrayList();
     CompanyauthExt companyauthext = new CompanyauthExt();
     companyauthext.setParam(":VCUST_ID", cust_id);
     arraylist = companyauthext.selByList("SEL_COMPANYAUTH_BY_CUST_ID_ALL");
     return arraylist;
   }
 
   public ArrayList selCompanyNumByCity(String area_id)
   {
     CustomerExt customerext = new CustomerExt();
     ArrayList comList = new ArrayList();
     customerext.setParam(":VEPARCHY_CODE", area_id + "%");
     comList = customerext.selByList("SEL_COMPANYNUM_BY_CITY");
     return comList;
   }
 }

